#include "stdio.h"

#define do_div(n, base) ({ \
    int __res; \
    __asm__("div %4": "=a"(n), "=d"(__res): "0"(n), "r" (base)); \
    __res;})

static char* digits = "01234567890";

int main(void)
{
    int x = 12345;
    int base = 10;
    char tmp[10];
    int i = 0;
    while (x) 
    {
        tmp[i++] = digits[do_div(x, base)];
    }
    // 预期输入 12345和54321
    printf("x:%d\n, tmp:%s\n", x, tmp);
    return 0;
}